/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package oids.frontEnd.components;

import java.awt.Color;
import java.awt.Graphics;
import oids.frontEnd.util.ComponentStepCalculation;
import oids.frontEnd.util.Point2D;

/**
 *
 * @author CJ
 */
public class Bullet extends Component{

    protected int xAddition;
    protected int yAddition;

    public static final int STEP_INTERVAL = Ship.STEP_FORWARD_INTERVAL + 1;
    public static final int CIRCLE_RADIUS = 4;

    public Bullet(Point2D startingPoint, double theta){
        super(startingPoint.getX(), startingPoint.getY(), Bullet.CIRCLE_RADIUS);
        setAdditives(theta);
    }

    public void draw(Graphics g){
        g.setColor(Color.green);
        g.fillOval(this.x - CIRCLE_RADIUS/2, this.y - CIRCLE_RADIUS/2, CIRCLE_RADIUS, CIRCLE_RADIUS);
    }

    protected void setAdditives(double theta){
        Point2D additives = ComponentStepCalculation.getStepInterval(theta, STEP_INTERVAL);
        this.xAddition = additives.getX();
        this.yAddition = additives.getY();
    }

    public void step(){
        stepThisBullet();
    }

    protected void stepThisBullet(){
        this.x += this.xAddition;
        this.y += this.yAddition;
    }



}
